<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table border="1">
    <tr>
        <th>id</th>
        <th>姓名</th>
        <th>工作</th>
        <th>年龄</th>
        <th>操作</th>
    </tr>
    <tr v-for="emp in arr">
        <td>{{emp.id}}</td>
        <td><a :href="'/update.html?id='+emp.id">{{emp.name}}</a></td>
        <td>{{emp.job}}</td>
        <td>{{emp.age}}</td>
        <td ><a href="#" @click="del(emp.id)">删除</a></td>
    </tr>
</table>
<!--引入vue框架-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>
    let v = new Vue({
        el:"table",
        data: {
            arr:[]
        },
        created: function () {
            axios.get("/select").then(function (response) {
                v.arr = response.data
            })
        },
        methods: {
            del:function (id) {
                if (confirm("删不删?")) {
                    axios.get("/delete?id="+id).then(function () {
                        alert("删除成功")
                        location.reload();
                    })
                }
            }
        }
    })
</script>
</body>
</html>